import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TInvestPlan } from "../../../Message/Db/Tables/TInvestPlan";
type int = number;
//class InvestmentConfig
    
    export  class InvestmentConfig
    {
        constructor()
        {
            
            if (InvestmentConfig._instance) 
            {
                throw new Error("InvestmentConfig单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_invest_plan.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            var loc4=0;
            var loc5=arg1;
            for(loc2 of loc5) 
            {
                loc1 = new TInvestPlan();
                var loc6=0;
                var loc7=loc2;
                for (loc3 in loc7) 
                {
                    if (!loc1.hasOwnProperty(loc3)) 
                    {
                        continue;
                    }
                    loc1[loc3] = loc2[loc3];
                }
                this._map[loc1.id] = loc1;
            }
            return;
        }

        public getDataByIds(arg1: Array<any>): Array<any>
        {
            var loc2=0;
            var loc1=[];
            if (arg1) 
            {
                loc2 = 0;
                while (loc2 < arg1.length) 
                {
                    if (this._map[arg1[loc2]]) 
                    {
                        loc1.push(this._map[arg1[loc2]]);
                    }
                    ++loc2;
                }
            }
            return loc1;
        }

        public getInfoById(arg1: int): TInvestPlan
        {
            return this._map[arg1] as TInvestPlan;
        }

        public getIncomeByInfo(arg1: TInvestPlan): int
        {
            var loc2=null;
            var loc3=0;
            var loc1=0;
            if (arg1) 
            {
                loc2 = arg1.rewardsAmount.split(",");
                loc3 = 0;
                while (loc3 < loc2.length) 
                {
                    if (loc2[loc3] != "") 
                    {
                        loc1 = loc1 + parseInt(loc2[loc3]);
                    }
                    ++loc3;
                }
            }
            return loc1;
        }

        public getIncomeById(arg1: int): int
        {
            return this.getIncomeByInfo(this._map[arg1] as TInvestPlan);
        }

        public static get instance(): InvestmentConfig
        {
            return InvestmentConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: InvestmentConfig;
    }

            InvestmentConfig._instance = new InvestmentConfig();
        